package cn.tedu.egmybatis1.mapper;

import cn.tedu.egmybatis1.pojo.entity.Product;
import cn.tedu.egmybatis1.pojo.vo.ProductVO1;
import cn.tedu.egmybatis1.pojo.vo.ProductVO2;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("INSERT INTO product (id,title,price,stock) VALUES (#{id},#{title},#{price},#{stock})")
    int insertProduct(Product product);

    @Select("SELECT title,price FROM product WHERE id=#{id}")
    ProductVO1 selectSingleProduct(int id);

    @Select("SELECT title,stock FROM product ")
    List<ProductVO2> selectManyProduct();

    @Delete("DELETE FROM product WHERE id=#{id}")
    int deleteById(int id);

}
